<?php

Yii::import('application.models._base.BaseDeudaSocio');

class DeudaSocio extends BaseDeudaSocio
{
	public static function model($className=__CLASS__) {
		return parent::model($className);
	}
	
	public function getSaldodeudasocio($id) {	
				$command=Yii::app()->db->createCommand();
				$command->select('SUM(Debe) AS montoDebe');
				$command->from('movcuentasocio');
				$command->where('DeudaSocioId='.$id);
				$debe=$command->queryScalar();
	
				$command=Yii::app()->db->createCommand();
				$command->select('SUM(Haber) AS montoHaber');
				$command->from('movcuentasocio');
				$command->where('DeudaSocioId='.$id);
				$haber=$command->queryScalar();
	
				return $debe-$haber;
	}
}